using System;
using System.Threading;

public partial class AddEnemyRobotState : BaseLevelState
{
    TimerAddRobot timerAddRobot;
    public override void _Ready()
    {
        base._Ready();
        timerAddRobot = GetNode<TimerAddRobot>("TimerAddRobot");
        timerAddRobot.OnAddRobotEnd += OnAddEnemyRobotEndHandler;
    }

    private void OnAddEnemyRobotEndHandler()
    {
        EmitSignal(SignalName.OnStateEnd, this);
    }


    public override void Enter()
    {
        base.Enter();
        var cfg = stateMachime.LevelManager.CurrentEvent?.RobotsData;
        if (cfg != null)
        {
            // AudioManager.PlayBgm(""); // TODO
            timerAddRobot.Start(cfg, false, false);
        }
        else
        {
            EmitSignal(SignalName.OnStateEnd, this);
        }
    }

    public override void Exit()
    {
        base.Exit();
    }
}
